import { __private, _decorator, Camera, Component, instantiate, Node, Prefab, Vec3, view } from 'cc';
import { ResMgr } from '../../../ISUtility/Script/ResMgr';
import { GameWorld } from '../GameWorld';
import { UIRoot } from '../../../ISUtility/Script/UI/UIRoot';
const { ccclass, property } = _decorator;

@ccclass('GameUnit')
export class GameUnit extends Component {

    private _vec3temp: Vec3 = new Vec3();

    public IsInView(): boolean {
        this.node.getWorldPosition(this._vec3temp);
        GameWorld.inst.Camera.convertToUINode(this._vec3temp, UIRoot.inst.node, this._vec3temp);
        let size = view.getVisibleSize();
        if (this._vec3temp.x > size.width / 2
            || this._vec3temp.x < -size.width / 2
            || this._vec3temp.y > size.height / 2
            || this._vec3temp.y < -size.height / 2) {
            return false;
        }
        return true;
    }
}


